
import com.Student;
import com.Student2;
import com.Teacher;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 *
 * Created with IntelliJ IDEA.
 * Description:
 * User: ling
 * Date: 2022-11-08
 * Time: 9:33
 */
public class App {
    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");
        Student student1 = (Student) context.getBean("student1");
        System.out.println(student1);
        Student student2 = (Student) context.getBean("student2");
        System.out.println(student2);

        Teacher teacher = (Teacher) context.getBean("teacher");
        System.out.println(teacher);

        Teacher teacher2 = (Teacher)context.getBean("teacherBean");
        Student2 stu2 = new Student2(teacher2,"小刘");
        stu2.study();
        System.out.println(stu2);
    }
}
